﻿namespace Mars.GameCore
{
    public static class StringExtension
    {
        /// <summary>
        /// 判断字符串是否以目标字符串结尾
        /// </summary>
        /// <param name="self"></param>
        /// <param name="target">目标字符串</param>
        /// <returns></returns>
        public static bool EndsWithFast(this string self, string target)
        {
            int ap = self.Length - 1;
            int bp = target.Length - 1;

            while (ap >= 0 && bp >= 0 && self[ap] == target[bp])
            {
                ap--;
                bp--;
            }

            return (bp < 0);
        }
    }
}